#!/usr/bin/env python
# -*- coding:utf-8 -*-
from django.shortcuts import render
from app01.forms import home as HomeForm
from app01 import models

def index(request):
    # models.UserInfo.objects.all.delete()
    # models.UserInfo.objects.create(name='user1')
    # after_list = models.UserInfo.objects.all()
    # print after_list[0].ctime
    ret = models.SimpleModel.objects.all()
    print ret.query
    ret = models.SimpleModel.objects.values('username')
    print ret,type(ret)
    ret = models.SimpleModel.objects.values_list('id','username')
    print ret,type(ret)

    obj = HomeForm.ImportForm()
    return render(request,'home/index.html',{'obj':obj})

def upload(request):
    if request.method=='POST':
        inp_post = request.POST
        inp_files = request.FILES
        file_obj1 = inp_files.get('f1')
        # print file_obj1.name
        f = open(file_obj1.name,'wb')
        for line in file_obj1.chunks():
            f.write(line)
        f.close()
    return render(request,'home/upload.html')

